const { db, query } = require("../../db/db");
const util = require("util");

async function GetKeyTipsList(req, res) {
  const Filter = req.body.Filter;

  if (Filter === "") {
    res.send({
      status: 0,
      KeyTipsList: [],
    });
  } else {
    const select_sql = util.format(
      'Select SearchSuggestionsName from Search_Suggestions where SearchSuggestionsName like "%%%s%"\
      ORDER BY CreateTime DESC LImit %s',
      Filter,
      10
    );

    const KeyTipsList = await query(select_sql);

    res.send({
      status: 0,
      KeyTipsList: KeyTipsList,
    });
  }
}

module.exports = { GetKeyTipsList };
